package app

import (
	"github.com/gin-gonic/gin"
	http2 "net/http"
	"time"
)

/**
 * Created with IntelliJ IDEA.
 * User: 令狐飞侠
 * Date: 2021-11-30
 * Description: gin 自定义http server
 */

func TestCustomHttpServer() {
	//定义router
	router := gin.Default()
	router.GET("/", func(context *gin.Context) {
		context.JSON(200, gin.H{
			"message": "我是自定义http server的相应!",
		})
	})
	//自定义http Server
	customHttp := &http2.Server{
		Addr:         ":8080",
		Handler:      router,
		ReadTimeout:  10 * time.Second,
		WriteTimeout: 10 * time.Second,
	}
	//启动服务
	customHttp.ListenAndServe()
}
